package com.qdu.reducer;

import com.qdu.bean.WeatherBean2;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RentPerMonthByWeatherReducer extends Reducer<WeatherBean2, IntWritable,WeatherBean2, IntWritable> {

    @Override
    protected void reduce(WeatherBean2 key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int count = 0;
        int sum = 0;
        for (IntWritable i:
             values) {
            sum += i.get();
            count++;
        }

        System.out.println(count);
        context.write(key,new IntWritable(sum));
    }
}